<?php


//displays the first part of the HTML (header, stylesheet links, javascript if needed, logo, etc.)
function displayPageTop($title, $javaScript = true){
    
    if($javaScript){
        $javaScript = displayJavaScript();
    }
    else{
        $javaScript = '';
    }
    
    
    $output = '
    
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> 
    <head> 
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
      <title>'.$title.'</title>
      <link rel="schema.DC" href="http://purl.org/dc/terms" />
      <meta name="DC.title" content="Open Context: Refine" />
      <meta name="DC.created" content="January 1, 2010" />
      <meta name="DC.date" content="January 1, 2011" />
      <meta name="DC.creator" content="Open Context Editors" />
      
      <link href="http://opencontext.org/css/new-oc-layout.css" rel="stylesheet" type="text/css" />
      <link href="http://opencontext.org/css/oc-about-layout.css" rel="stylesheet" type="text/css" /> 
      <link rel="shortcut icon" href="http://opencontext.org/images/layout/oc-favicon.ico" type="image/x-icon" />
      
      '.$javaScript.'
      
    </head>
    
<body>

    <div id="headerTop">

    <div id="headerTopContent">

        <div id="headerTopLogoArea">

            <div id="headerTopLogoRow">

                <div id="headerTopLogoCellImage">

                    <a href="http://opencontext.org/" title="Open Context (Home)"><img src="http://opencontext.org/images/layout/oc-door-logo.png" alt="Open Context Logo"/></a>

                </div>

                <div id="headerTopLogoCellText">

                    <a href="http://opencontext.org/" title="Open Context (Home)">Open Context</a>

                </div>

            </div>

            <div id="headerTopLogoTagLine">

                Web-based research data publication

            </div>

        </div>

        

        <div id="headerMiddleArea">

        </div>

    </div>

</div>   

<!-- 

    Navigation tabs

-->


<div id="headerNav">

    <div id="headerNavContent">

    </div>

</div>
  
    ';
    
    return $output;
}

//displays javascript for the login page
function displayJavaScript(){
    
    global $issueTrackerBaseURL;
    global $sessionID;
    global $publicBaseURL; 
    
    
    $output = '
    
    
    <script src="http://code.jquery.com/jquery-latest.js"></script>
      
      <script type="text/javascript">
	
	var baseIssuesURI = "'.$issueTrackerBaseURL.'"; // Base URI for Mantis
	var authorizationURI = "/plugin.php";
	var sessID = "'.$sessionID.'";
	
	$.getJSON( baseIssuesURI + authorizationURI + "?callback=?",
	{
	  page: "DataRefine/loginOK",
	  grSession: sessID
	},
	function(data) {
            var okMessage = "Congrats! You are logged in as \'" + data.userName + "\'. <a href=\''.$publicBaseURL.'/\'>Click here</a> to continue.";
            document.getElementById(\'loginOK\').innerHTML = okMessage ;
	});
      
      </script>
    
    
    ';
    
    return $output;
}

//displays the bottom part of the HTML page
function displayPageBottom(){
    
    $output = '
    
    <div id="bottom">
	</div>
	
    </div>
    <div id="footerTop">
        <p class="bodyText" style="text-align:center;">Refine deployment and authentication uses 100% open-source components integrated by Eric Kansa for Open Context.</p>
    </div>
    <div id="footerLower">
    </div>
</body>
</html>
    
    ';
    
    return $output;
}


//diplays the HTML for the login page
function displayLoginPage(){
    
    global $issueTrackerBaseURL;
    global $publicBaseURL; 

    
    $output = '
    
        <div id="main">
	<div id="pageTop">
            <div id="pageIntro">
                <h2 style="text-align:center;">Open Context: Google Refine Data Editing Tool</h2>
                
                <div style="margin:10px;">
                    <p class="bodyText">Open Context deploys <a href="http://code.google.com/p/google-refine/">Google Refine</a> to provide a
                    collaborative platform for its editors to review datasets and improve data quality. Google Refine has a suite of powerful features to edit and clean up data tables. Because Google Refine logs all changes, edits can be rolled back if needed. The logging also provides additional transparency to the data clean-up processes and the edit-logs can be archived along with the cleaned data.
                    </p>
                    
                    <p class="bodyText">This collaborative workspace supports editting of active projects prior to publication. Access to this workspace lies behind a login barrier. User accounts and permissions are managed by Open Context\'s Issue Tracker (<a href="http://www.mantisbt.org/">Mantis</a>).
                    </p>
                </div>
            </div>
            
            <div id="pageTopEnd">
                <br/>
            </div>
        </div>
        
        
        <br/>
        <div style="margin:10px;">
            <h3>Login</h3>
	      
	    <p class="bodyText">You must be logged into Open Context\'s issue tracker before you can use Open Context\'s Google Refine tool.
            This page verifies your login status when it loads. If you are not logged in, you will see a message with login instructions below.
            </p>
            <br/>
            <br/>
            <p class="bodyText">Login Status:</p>
            <h3 id="loginOK">It looks like you are not logged into Open Context\'s Issue Tracker. <a href="'.$issueTrackerBaseURL.'">Click Here</a> to Login.</h3>
            <br/>
            <br/>
            <br/>
            <br/>
        </div>

    ';
    
    return $output;
}




//diplays the HTML for the login page
function displayEditIssue($editIssue){
    
    global $issueTrackerBaseURL;
    
    $output = '
    
        <div id="main">
	<div id="pageTop">
            <div id="pageIntro">
                <h2 style="text-align:center;">Open Context: Google Refine Data Editing Tool</h2>
                
                <div style="margin:10px;">
                    <p class="bodyText">Edits on this dataset are complete. This dataset cannot be edited further, because the issue tracking edits for this dataset has been resolved or closed. Additional edits are not allowed, because these edits may conflict with work to document the dataset.
                    </p>
                    
                    <p class="bodyText">If you need to re-open edits to this dataset, please <a href="'.$issueTrackerBaseURL.'/view.php?id='.$editIssue.'">click here</a>.
                    </p>
                </div>
            </div>
            
            <div id="pageTopEnd">
                <br/>
            </div>
        </div>
        
        
        <br/>
        

    ';
    
    return $output;
}


?>